package com.example.wm.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.wm.OV.TenderEntityVo;
import com.example.wm.common.Result;
import com.example.wm.common.ResultData;
import com.example.wm.entity.TenderDetails;
import com.example.wm.entity.TenderImages;
import com.example.wm.service.TenderImagesService;
import com.example.wm.utils.TsyUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("/TenderImages")
@CrossOrigin
public class TenderImagesContoller {
    @Resource
    private TenderImagesService tenderImagesService;
    @Resource
    private TsyUtils tsyUtils;
    @PostMapping("/save")
    public Result save(@RequestBody TenderImages tenderImages) {

        tenderImages.setInsertime(tsyUtils.getnowtime());
      Boolean b=  tenderImagesService.save(tenderImages);
        return ResultData.success(b);
    }
    @PostMapping("/saveBatch")
    public Result saveBatch(@RequestBody List<TenderImages> tenderImagesList) {
          for(TenderImages img:tenderImagesList){
              img.setInsertime(tsyUtils.getnowtime());
          }
       tenderImagesService.saveBatch(tenderImagesList);
        return ResultData.success();
    }
    @PostMapping("/find")
    public Result find(@RequestBody TenderImages tenderImages) {

        LambdaQueryWrapper<TenderImages> lq=new LambdaQueryWrapper<>();
        lq.eq(TenderImages::getTenderid,tenderImages.getTenderid());
        lq.eq(TenderImages::getStatus,tenderImages.getStatus());
        List<TenderImages> tenderImages1=tenderImagesService.list(lq);
        return ResultData.success(tenderImages1);
    }
}
